#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n;
char s[N];
int dp[N];
int f[N], g[N];
void manacher() {
  int C = 1, R = 2;
  dp[1] = 1;
  rep(i, 2, n) {
    if (i < R)
      dp[i] = min(R - i, dp[C * 2 - i]);
    else
      dp[i] = 1;
    while (s[i + dp[i]] == s[i - dp[i]]) dp[i]++;
    if (i + dp[i] > R) R = i + dp[i], C = i;
  }
}
void init() {
  queue<int> q1;
  rep(i, 1, n) {
    while (q1.size() && q1.front() + dp[q1.front()] <= i) q1.pop();
    if (q1.empty() || (q1.size() && q1.back() + dp[q1.back()] < i + dp[i]))
      q1.push(i);
    f[i] = i - q1.front();
  }
  queue<int> q2;
  per(i, n, 1) {
    while (q2.size() && q2.front() - dp[q2.front()] >= i) q2.pop();
    if (q2.empty() || (q2.size() && q2.back() - dp[q2.back()] > i - dp[i]))
      q2.push(i);
    g[i] = q2.front() - i;
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string t;
  cin >> t;
  s[0] = '^';
  for (char c : t) {
    s[++n] = '#';
    s[++n] = c;
  }
  s[++n] = '#';
  s[n + 1] = '$';
  manacher();
  init();
  int ans = 0;
  rep(i, 2, n - 1) if (s[i] == '#') ans = max(ans, f[i] + g[i]);
  cout << ans;
  return 0;
}